/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package network.packets;

import utils.StringUtils;
import utils.Utils;


/**
 *
 * @author kvest
 */
public class ServerMessage extends Packet
{
    private String message;
    
    public ServerMessage(byte[] data)
    {
        super(SERVER_MESSAGE_RESPONCE, data);
    }

    public void parse(byte[] data)
    {
        int offset = 2;

        //Текст объявлений
        byte[] tmp = new byte[4];
        System.arraycopy(data, offset, tmp, 0, tmp.length);
        offset += tmp.length;
        tmp = new byte[Utils.byteToInt(tmp)];
        System.arraycopy(data, offset, tmp, 0, tmp.length);
        offset += tmp.length;
        message = StringUtils.bytesToStr(tmp);
    }

    public void print()
    {
        System.out.println("ServerMessage={" + message + "}");
    }

    public String getMessage()
    {
        return message;
    }
}
